<template>
	<view>
		<view class="my-header">
			<view @click="isLogin" class="header-content space-between center">
				<view class="left center">
					<image class="header-image" :src="userInfo.imageUrl || '/static/logo.png'"></image>
					<view v-if="userInfo" class="header-info column">
						<text class="nickname">{{userInfo.nickName}}</text>
						<text class="username">用户名：{{userInfo.username}}</text>
					</view>
					<view v-else class="header-info">
						<text class="nickname">请登录</text>
					</view>
				</view>
				<text class="iconfont icon-right"></text>
			</view>
		</view>
		<view style="height: 20rpx;background: #f8f9fb;"></view>
		<view class="nav">
			<card>我的订单</card>
			<card>我的余额</card>
			<card>我的学习</card>
			<view style="height: 20rpx;background: #f8f9fb;"></view>
			<card>设置</card>
			<card>意见反馈</card>
			<view style="height: 20rpx;background: #f8f9fb;"></view>
			<card>关于我们</card>
		</view>


	</view>
</template>

<script>
	// import { mapState,mapGetters } from 'vuex'
	import card from "@/common/my_card.vue"
	export default {
		data() {
			return {
				userInfo: {}
			}
		},
		components: {
			card
		},
		onShow() {
			this.userInfo = uni.getStorageSync('userInfo')
		},
		computed: {
		},

		methods: {
			// 判断是否登录
			isLogin() {
				// console.log('登录',this.hasLogin);
				if (this.userInfo) {
					
					uni.navigateTo({
						url: './user'
					})
				} else {
					console.log('没有登录');
					uni.navigateTo({
						url: '/pages/auth/login',
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	// 登录页面
	.my-header {
		background-color: #335dc0;
		padding-top: 95rpx;

		.header-content {
			// margin-top: 40rpx;
			padding: 50rpx 39rpx;
			background-color: #FFFFFF;
			border-radius: 30rpx 30rpx 0 0;
		}

		.left {
			.header-image {
				width: 150rpx;
				height: 150rpx;
				border-radius: 80rpx;
			}

			.header-info {
				margin-left: 30rpx;

				.nickname {
					font-size: 39rpx;
					font-weight: bold;
				}

				.username {
					font-size: 33rpx;
					color: grey;
				}
			}
		}

		.icon-right {
			font-size: 35rpx;
			color: grey;
		}
	}

	.nav {
		width: 100%;
		box-sizing: border-box;
	}
</style>
